
import { getGoodsSpecGroupAllList } from '@/api/goods/goodsSpecGroup';
import { getDicts } from '@/api/system/dict/data/index';

import { getUserNotPermission } from '@/api/system/user';
import { listFollowStatus } from '@/api/goods/followStatus';
import { listFollowType } from '@/api/goods/followType';
import {  getUserAllList } from '@/api/system/user';
import { getClassifyTree } from '@/api/goods/classify/index'
// 任务类型
import { listTaskType } from '@/api/goods/taskType'
import moment from 'moment'
export default {
    data() {
        return {
            goodsSpecGroupList: [],
            assistList: [],//后台用户

            goods_price_type: [],
            follow_stage:[],
            followTypes:[],//跟单类型
            taskTypes:[],//任务类型
            classifyList:[],
        }
    },
    methods: {
        moment,
        // 获取规格组
        getGoodsSpecGroupAllList() {
            getGoodsSpecGroupAllList().then(res => {
                this.goodsSpecGroupList = res
            }).catch(err => {
                console.log(err)
            });
        },

        // 后台用户
        getUserNotPermission() {
            getUserNotPermission()
                .then((res) => {
                    this.assistList = res;
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        // 所有后台用户
        getUserAllList() {
            getUserAllList()
                .then((res) => {
                    this.userList = res;
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        /**
         * @获取字典
         */
        async getDicts(dictType) {
            let arr = []
            if (Array.isArray(dictType)) {
                arr = dictType
            } else {
                arr.push(dictType)
            }
            for (var i = 0; i < arr.length; i++) {
                await getDicts(arr[i]).then(res => {
                    if (res.code == 200) {
                        this[arr[i]] = (res.data || []).map(item => {
                            return {
                                label: item.dictLabel,
                                value: item.dictValue
                            }
                        })
                    } else {
                        this.$modal.msgError(res.msg)
                    }
                });
            }
        },
        //   获取跟单状态
        listFollowStatus() {
            listFollowStatus().then(res => {
                this.follow_stage = res.rows
            }).catch(err => {
                console.log(err)
            });
        },
        listFollowType(type){
            listFollowType({
                pageNum: 1,
                pageSize: 999,
                typeCategory:type
            }).then(res => {
                this.followTypes = res.rows
            }).catch(err => {
                console.log(err)
            });
        },
        
        /**
         * @获取供应商或客户树
         */
        getClassifyTree(type, callback) {
            getClassifyTree(type).then(res => {
                this.classifyList = [
                    {
                        id: '',
                        label: '全部',
                        children: res.data
                    }
                ]
                console.log(this.classifyList,666);
                callback && callback(res)
            });
        },
        /**
         * 获取任务类型
         */
        listTaskType(){
            listTaskType().then(res => {
                this.taskTypes = res.rows
            }).catch(err => {
                console.log(err)
            });
        }
    },
}